<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的订单</title>
</head>
<body>
    <?php
    require_once("DButil.php");
    echo 'u_id:' . ($_SESSION['u_id']);//把登录的用户
    echo '<br>';
    $sql="select o_id,o_no,o_num,o_total from t_order where u_id={$_SESSION['u_id']}";
    $sql1="select u_login_name from t_user where u_id={$_SESSION['u_id']}";
    $conn=getConn();
    $result = mysqli_query($conn, $sql);
    $result1=mysqli_query($conn, $sql1);
    if($result1){
        $row1 = mysqli_fetch_assoc($result1);
        // var_dump( $row1);
        echo "用户：" . $row1["u_login_name"] . "的订单如下。" . "<br>";
    }
    if($result){
        // echo '<br>';
        echo "<table border='1' cellpadding='10' cellspacing='0' >
        <thead>
            <tr>
                <td>编号</td>
                <td>订单业务编号</td>
                <td>总数量</td>
                <td>总金额</td>
            </tr>
        </thead>
        <tbody>";
        // echo '<hr>';
        echo '数据行数:' . mysqli_num_rows($result);//数据行数
        $length=mysqli_num_rows($result);
        echo '<br>';
        $row = mysqli_fetch_assoc($result);
        for($i=0;$i<$length;$i++){
            echo "<tr>
                <td>{$row['o_id']}</td>
                <td>{$row['o_no']}</td>
                <td>{$row['o_num']}</td>
                <td>{$row['o_total']}</td>
            </tr>";
        }
        echo "</tbody></table>";
    }
    mysqli_close($conn);
    ?>
</body>
</html>